<!--
 * Description: 报价专案修改页面
 * Company: 联宝（合肥）电子科技有限公司
 * Author: Dongxu.Ni
 * Date: 2020/03/31 07:26
-->

<template>
  <div>
    <!--数据表单-->
    <el-form label-width="80px" :model="formData" size="mini">
      <el-row>
        <!--专案编号-->
        <el-col :span="12">
          <el-form-item label="专案编号" label-width="150px">
            <el-input
              v-model="formData.projectId"
              v-blur:projectId="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--专案名称-->
        <el-col :span="12">
          <el-form-item label="专案名称" label-width="150px">
            <el-input
              v-model="formData.projectName"
              v-blur:projectName="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--专案描述-->
        <el-col :span="12">
          <el-form-item label="专案描述" label-width="150px">
            <el-input
              v-model="formData.projectDesc"
              v-blur:projectDesc="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--IDP的PM，域名-->
        <el-col :span="12">
          <el-form-item label="PM" label-width="150px">
            <el-input
              v-model="formData.pm"
              v-blur:pm="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--系列-->
        <el-col :span="12">
          <el-form-item label="系列" label-width="150px">
            <el-input
              v-model="formData.series"
              v-blur:series="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--BU类型 LNB/TNB/Server-->
        <el-col :span="12">
          <el-form-item label="BU类型" label-width="150px">
            <el-select v-model="formData.bu" clearable :placeholder="$t('select.placeholder')">
              <el-option
                v-for="item in $store.getters['enums/getBuList']"
                :key="item"
                :label="item"
                :value="item"
              />
            </el-select>
          </el-form-item>
        </el-col>

        <!--biz类型-->
        <el-col :span="12">
          <el-form-item label="biz类型" label-width="150px">
            <el-input
              v-model="formData.bizType"
              v-blur:bizType="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--customerName-->
        <el-col :span="12">
          <el-form-item label="customerName" label-width="150px">
            <el-date-picker
              v-model="formData.customerName"
              type="datetime"
              value-format="yyyy-MM-dd HH:mm:ss[.999]"
            />
          </el-form-item>
        </el-col>

        <!--项目详细设计开始时间-->
        <el-col :span="12">
          <el-form-item label="详细设计开始时间" label-width="150px">
            <el-date-picker
              v-model="formData.dds"
              type="datetime"
              value-format="yyyy-MM-dd HH:mm:ss[.999]"
            />
          </el-form-item>
        </el-col>

        <!--财务编码-->
        <el-col :span="12">
          <el-form-item label="财务编码" label-width="150px">
            <el-input
              v-model="formData.financeCode"
              v-blur:financeCode="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--代-->
        <el-col :span="12">
          <el-form-item label="代" label-width="150px">
            <el-input
              v-model="formData.generation"
              v-blur:generation="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--model类型-->
        <el-col :span="12">
          <el-form-item label="model类型" label-width="150px">
            <el-input
              v-model="formData.modelType"
              v-blur:modelType="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--成本中心-->
        <el-col :span="12">
          <el-form-item label="成本中心" label-width="150px">
            <el-input
              v-model="formData.profitCenter"
              v-blur:profitCenter="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--program-->
        <el-col :span="12">
          <el-form-item label="program" label-width="150px">
            <el-input
              v-model="formData.program"
              v-blur:program="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--项目编码-->
        <el-col :span="12">
          <el-form-item label="项目编码" label-width="150px">
            <el-input
              v-model="formData.projectNumber"
              v-blur:projectNumber="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--项目类型-->
        <el-col :span="12">
          <el-form-item label="项目类型" label-width="150px">
            <el-input
              v-model="formData.projectType"
              v-blur:projectType="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--备注-->
        <el-col :span="12">
          <el-form-item label="备注" label-width="150px">
            <el-input
              v-model="formData.remark"
              v-blur:remark="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--项目推向市场时间-->
        <el-col :span="12">
          <el-form-item label="项目推向市场时间" label-width="150px">
            <el-input
              v-model="formData.ss"
              v-blur:ss="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--状态-->
        <el-col :span="12">
          <el-form-item label="状态" label-width="150px">
            <el-input
              v-model="formData.state"
              v-blur:state="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--tdmsName-->
        <el-col :span="12">
          <el-form-item label="tdmsName" label-width="150px">
            <el-input
              v-model="formData.tdmsName"
              v-blur:tdmsName="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--teamLocation-->
        <el-col :span="12">
          <el-form-item label="teamLocation" label-width="150px">
            <el-input
              v-model="formData.teamLocation"
              v-blur:teamLocation="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>

        <!--系统版本-->
        <el-col :span="12">
          <el-form-item label="系统版本" label-width="150px">
            <el-input
              v-model="formData.version"
              v-blur:version="formData"
              clearable
              :placeholder="$t('input.placeholder')"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span style="display: block;text-align: center;margin-top: 5px">
      <!--取消按钮-->
      <el-button size="medium" @click="cancel">{{ $t('button.cancel') }}</el-button>
      <!--保存按钮-->
      <el-button size="medium" type="primary" @click="save">{{ $t('button.save') }}</el-button>
    </span>
  </div>
</template>

<script>
import { projectEdit } from '@/api/quote/project'

export default {
  name: 'ProjectDataLocalEdit',
  props: {
    inputData: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      formData: {}
    }
  },
  computed: {},
  watch: {},
  created() {
    this.pageDataInit()
  },
  mounted() {},
  methods: {
    pageDataInit() {
      // 将props传入的值复制给formData的值
      this.formData = JSON.parse(JSON.stringify(this.inputData))
    },
    save() {
      this.$confirmBox(this.$t('button.save'), 'success')
        .then(() => {
          projectEdit(this.formData, { msgSuccess: true, msgError: true }).then(() => {
            this.$emit('save')
          })
        })
        .catch(cancel => cancel)
    },
    cancel() {
      this.$emit('cancel')
    }
  }
}
</script>

<style></style>
